package main.servlet.service.impl;

import java.util.List;

import main.dao.UserDao;
import main.dao.impl.UserDaoImpl;
import main.pojo.User;
import main.servlet.service.RegisterService;
import main.servlet.service.listener.RegisterListener;

public class RegisterServiceImpl implements RegisterService{

	private RegisterListener mListener;
	
	public RegisterServiceImpl(RegisterListener listener){
		this.mListener  = listener;
	}
	
	@Override
	public void registerUserToDB(User user) {
		UserDao userDao = new UserDaoImpl();
		userDao.addUser(user);
		
		List<User> userList = userDao.findAll();
		if(this.mListener!=null)
			this.mListener.finishRegister(userList);
	}

}
